{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Fiji</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Papua New Guinea</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "      <td>5.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3257 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year       WHO region                   Country Beverage Types  \\\n",
       "0     1986  Western Pacific                  Viet Nam           Wine   \n",
       "1     1986         Americas                   Uruguay          Other   \n",
       "2     1985           Africa              Cte d'Ivoire           Wine   \n",
       "3     1986         Americas                  Colombia           Beer   \n",
       "4     1987         Americas     Saint Kitts and Nevis           Beer   \n",
       "...    ...              ...                       ...            ...   \n",
       "3252  1984           Africa  Central African Republic           Wine   \n",
       "3253  1986  Western Pacific                      Fiji        Spirits   \n",
       "3254  1986           Europe               Switzerland        Spirits   \n",
       "3255  1987  Western Pacific          Papua New Guinea          Other   \n",
       "3256  1986           Africa                 Swaziland          Other   \n",
       "\n",
       "      Display Value  \n",
       "0              0.00  \n",
       "1              0.50  \n",
       "2              1.62  \n",
       "3              4.27  \n",
       "4              1.98  \n",
       "...             ...  \n",
       "3252           0.46  \n",
       "3253           0.05  \n",
       "3254           2.54  \n",
       "3255           0.00  \n",
       "3256           5.15  \n",
       "\n",
       "[3257 rows x 5 columns]"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con = pd.read_csv('https://raw.githubusercontent.com/ustutz/Dataquest/master/Data_Analyst/Step_2_Intermediate_Python_and_Pandas/2_Data_Analysis_with_Pandas_Intermediate/2_Computation_with_NumPy/5_Replacing_values/world_alcohol.csv')\n",
    "w_a_con"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Shape of the dataframe:  (3257, 5)\n",
      "\n",
      "Number of rows:  3257\n",
      "\n",
      "Number of column:  5\n"
     ]
    }
   ],
   "source": [
    "print('\\nShape of the dataframe: ',w_a_con.shape)\n",
    "print('\\nNumber of rows: ',w_a_con.shape[0])\n",
    "print('\\nNumber of column: ',w_a_con.shape[1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year       WHO region                Country Beverage Types  Display Value\n",
       "0  1986  Western Pacific               Viet Nam           Wine           0.00\n",
       "1  1986         Americas                Uruguay          Other           0.50\n",
       "2  1985           Africa           Cte d'Ivoire           Wine           1.62\n",
       "3  1986         Americas               Colombia           Beer           4.27\n",
       "4  1987         Americas  Saint Kitts and Nevis           Beer           1.98"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Extract Column Names:\n",
      "Index(['Year', 'WHO region', 'Country', 'Beverage Types', 'Display Value'], dtype='object')\n"
     ]
    }
   ],
   "source": [
    "print(\"\\nExtract Column Names:\")\n",
    "print(w_a_con.columns)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to select first 2 rows, 2 columns and specific two columns from World alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select first 2 rows:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year       WHO region   Country Beverage Types  Display Value\n",
       "0  1986  Western Pacific  Viet Nam           Wine            0.0\n",
       "1  1986         Americas   Uruguay          Other            0.5"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect first 2 rows:\")\n",
    "w_a_con.iloc[:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year       WHO region   Country Beverage Types  Display Value\n",
       "0  1986  Western Pacific  Viet Nam           Wine            0.0\n",
       "1  1986         Americas   Uruguay          Other            0.5"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select first 2 columns:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year       WHO region\n",
       "0  1986  Western Pacific\n",
       "1  1986         Americas\n",
       "2  1985           Africa\n",
       "3  1986         Americas\n",
       "4  1987         Americas"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect first 2 columns:\")\n",
    "w_a_con.iloc[:,:2].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select 2 specific columns:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Display Value</th>\n",
       "      <th>Year</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.00</td>\n",
       "      <td>1986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.50</td>\n",
       "      <td>1986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.62</td>\n",
       "      <td>1985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.27</td>\n",
       "      <td>1986</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.98</td>\n",
       "      <td>1987</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Display Value  Year\n",
       "0           0.00  1986\n",
       "1           0.50  1986\n",
       "2           1.62  1985\n",
       "3           4.27  1986\n",
       "4           1.98  1987"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect 2 specific columns:\")\n",
    "w_a_con[['Display Value', 'Year']].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to select random number of rows, fraction of random rows from World alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select random number of rows:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2641</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Benin</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.85</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Bolivia (Plurinational State of)</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>249</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Dominican Republic</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2529</th>\n",
       "      <td>1985</td>\n",
       "      <td>South-East Asia</td>\n",
       "      <td>India</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>637</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>United Republic of Tanzania</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year       WHO region                           Country Beverage Types  \\\n",
       "2641  1984           Africa                             Benin           Beer   \n",
       "64    1989         Americas  Bolivia (Plurinational State of)           Beer   \n",
       "249   1986         Americas                Dominican Republic           Beer   \n",
       "2529  1985  South-East Asia                             India           Wine   \n",
       "637   1985           Africa       United Republic of Tanzania           Wine   \n",
       "\n",
       "      Display Value  \n",
       "2641           0.85  \n",
       "64             1.26  \n",
       "249            1.24  \n",
       "2529           0.00  \n",
       "637            0.00  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect random number of rows:\")\n",
    "w_a_con.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select fraction of randome rows:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2842</th>\n",
       "      <td>1985</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Jordan</td>\n",
       "      <td>Other</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>353</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Portugal</td>\n",
       "      <td>Beer</td>\n",
       "      <td>3.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2753</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Belize</td>\n",
       "      <td>Other</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2324</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Kyrgyzstan</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>1.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1205</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Bulgaria</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>3.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>151</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Peru</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1493</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Congo</td>\n",
       "      <td>Beer</td>\n",
       "      <td>2.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1438</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Togo</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>301</th>\n",
       "      <td>1987</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Morocco</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2672</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Guinea</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>65 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year             WHO region     Country Beverage Types  Display Value\n",
       "2842  1985  Eastern Mediterranean      Jordan          Other            NaN\n",
       "353   1986                 Europe    Portugal           Beer           3.00\n",
       "2753  1989               Americas      Belize          Other            NaN\n",
       "2324  1987                 Europe  Kyrgyzstan        Spirits           1.59\n",
       "1205  1989                 Europe    Bulgaria        Spirits           3.98\n",
       "...    ...                    ...         ...            ...            ...\n",
       "151   1989               Americas        Peru        Spirits           2.99\n",
       "1493  1985                 Africa       Congo           Beer           2.67\n",
       "1438  1987                 Africa        Togo        Spirits           0.28\n",
       "301   1987  Eastern Mediterranean     Morocco          Other           0.00\n",
       "2672  1986                 Africa      Guinea        Spirits           0.07\n",
       "\n",
       "[65 rows x 5 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect fraction of randome rows:\")\n",
    "w_a_con.sample(frac=0.02)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find and drop the missing values from World alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Missing values:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3257 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       Year  WHO region  Country  Beverage Types  Display Value\n",
       "0     False       False    False           False          False\n",
       "1     False       False    False           False          False\n",
       "2     False       False    False           False          False\n",
       "3     False       False    False           False          False\n",
       "4     False       False    False           False          False\n",
       "...     ...         ...      ...             ...            ...\n",
       "3252  False       False    False           False          False\n",
       "3253  False       False    False           False          False\n",
       "3254  False       False    False           False          False\n",
       "3255  False       False    False           False          False\n",
       "3256  False       False    False           False          False\n",
       "\n",
       "[3257 rows x 5 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nMissing values:\")\n",
    "w_a_con.isnull()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Dropping the missing values:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Fiji</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Papua New Guinea</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "      <td>5.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3035 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year       WHO region                   Country Beverage Types  \\\n",
       "0     1986  Western Pacific                  Viet Nam           Wine   \n",
       "1     1986         Americas                   Uruguay          Other   \n",
       "2     1985           Africa              Cte d'Ivoire           Wine   \n",
       "3     1986         Americas                  Colombia           Beer   \n",
       "4     1987         Americas     Saint Kitts and Nevis           Beer   \n",
       "...    ...              ...                       ...            ...   \n",
       "3252  1984           Africa  Central African Republic           Wine   \n",
       "3253  1986  Western Pacific                      Fiji        Spirits   \n",
       "3254  1986           Europe               Switzerland        Spirits   \n",
       "3255  1987  Western Pacific          Papua New Guinea          Other   \n",
       "3256  1986           Africa                 Swaziland          Other   \n",
       "\n",
       "      Display Value  \n",
       "0              0.00  \n",
       "1              0.50  \n",
       "2              1.62  \n",
       "3              4.27  \n",
       "4              1.98  \n",
       "...             ...  \n",
       "3252           0.46  \n",
       "3253           0.05  \n",
       "3254           2.54  \n",
       "3255           0.00  \n",
       "3256           5.15  \n",
       "\n",
       "[3035 rows x 5 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nDropping the missing values:\")\n",
    "w_a_con.dropna()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to remove the duplicates from 'WHO region' column of World alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1984</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>1984</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Norway</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1986</td>\n",
       "      <td>South-East Asia</td>\n",
       "      <td>Myanmar</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Year             WHO region       Country Beverage Types  Display Value\n",
       "0   1986        Western Pacific      Viet Nam           Wine           0.00\n",
       "1   1986               Americas       Uruguay          Other           0.50\n",
       "2   1985                 Africa  Cte d'Ivoire           Wine           1.62\n",
       "13  1984  Eastern Mediterranean   Afghanistan          Other           0.00\n",
       "18  1984                 Europe        Norway        Spirits           1.62\n",
       "20  1986        South-East Asia       Myanmar           Wine           0.00"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con.drop_duplicates('WHO region')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the alcohol consumption of a given year from the world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The world alcohol consumption details in the year 1985:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Angola</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>1985</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Lao People's Democratic Republic</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1985</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Comoros</td>\n",
       "      <td>Other</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Mauritania</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Lithuania</td>\n",
       "      <td>Other</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Year       WHO region                                            Country  \\\n",
       "2   1985           Africa                                       Cte d'Ivoire   \n",
       "7   1985           Africa                                             Angola   \n",
       "12  1985  Western Pacific                   Lao People's Democratic Republic   \n",
       "14  1985  Western Pacific                                           Viet Nam   \n",
       "24  1985           Africa                                            Comoros   \n",
       "26  1985           Europe  United Kingdom of Great Britain and Northern I...   \n",
       "33  1985           Africa                                         Mauritania   \n",
       "35  1985         Americas                              Saint Kitts and Nevis   \n",
       "44  1985           Europe                                          Lithuania   \n",
       "50  1985           Europe                                        Switzerland   \n",
       "\n",
       "   Beverage Types  Display Value  \n",
       "2            Wine           1.62  \n",
       "7         Spirits           0.39  \n",
       "12           Beer           0.00  \n",
       "14        Spirits           0.05  \n",
       "24          Other            NaN  \n",
       "26           Wine           1.36  \n",
       "33          Other           0.00  \n",
       "35        Spirits           2.24  \n",
       "44          Other            NaN  \n",
       "50          Other           0.30  "
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nThe world alcohol consumption details in the year 1985:\")\n",
    "w_a_con[w_a_con['Year']==1985].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The world alcohol consumption details in the year 1989:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Seychelles</td>\n",
       "      <td>Beer</td>\n",
       "      <td>2.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3227</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Bolivia (Plurinational State of)</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3228</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Madagascar</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3231</th>\n",
       "      <td>1989</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Morocco</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3246</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Poland</td>\n",
       "      <td>Beer</td>\n",
       "      <td>2.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3249</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Turkey</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>655 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year             WHO region                           Country  \\\n",
       "11    1989               Americas                         Guatemala   \n",
       "17    1989                 Africa                        Seychelles   \n",
       "21    1989               Americas                        Costa Rica   \n",
       "32    1989                 Africa                         Mauritius   \n",
       "45    1989                 Africa                          Zimbabwe   \n",
       "...    ...                    ...                               ...   \n",
       "3227  1989               Americas  Bolivia (Plurinational State of)   \n",
       "3228  1989                 Africa                        Madagascar   \n",
       "3231  1989  Eastern Mediterranean                           Morocco   \n",
       "3246  1989                 Europe                            Poland   \n",
       "3249  1989                 Europe                            Turkey   \n",
       "\n",
       "     Beverage Types  Display Value  \n",
       "11             Beer           0.62  \n",
       "17             Beer           2.23  \n",
       "21          Spirits           4.51  \n",
       "32             Beer           1.60  \n",
       "45             Beer           0.19  \n",
       "...             ...            ...  \n",
       "3227           Wine           0.08  \n",
       "3228           Wine           0.19  \n",
       "3231        Spirits           0.07  \n",
       "3246           Beer           2.03  \n",
       "3249          Other           0.00  \n",
       "\n",
       "[655 rows x 5 columns]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nThe world alcohol consumption details in the year 1989:\")\n",
    "w_a_con[w_a_con['Year']==1989]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the alcohol consumption details in the year '1987' or '1989' from the world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The world alcohol consumption details where year is 1987 or 1989:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Botswana</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Guinea-Bissau</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Seychelles</td>\n",
       "      <td>Beer</td>\n",
       "      <td>2.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.60</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Year       WHO region                Country Beverage Types  Display Value\n",
       "4   1987         Americas  Saint Kitts and Nevis           Beer           1.98\n",
       "5   1987         Americas              Guatemala          Other           0.00\n",
       "6   1987           Africa              Mauritius           Wine           0.13\n",
       "10  1987           Africa               Botswana           Wine           0.20\n",
       "11  1989         Americas              Guatemala           Beer           0.62\n",
       "15  1987           Africa          Guinea-Bissau           Wine           0.07\n",
       "17  1989           Africa             Seychelles           Beer           2.23\n",
       "21  1989         Americas             Costa Rica        Spirits           4.51\n",
       "28  1987  Western Pacific               Viet Nam           Beer           0.11\n",
       "32  1989           Africa              Mauritius           Beer           1.60"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nThe world alcohol consumption details where year is 1987 or 1989:\")\n",
    "w_a_con[(w_a_con['Year']==1987) | (w_a_con['Year']==1989)].head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the alcohol consumption details by the 'Americas' in the year '1985' from the world alcohol consumption dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>110</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Brazil</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Chile</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>258</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Bahamas</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>298</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Argentina</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3092</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3093</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Trinidad and Tobago</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3121</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Paraguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3146</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Lucia</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3159</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Peru</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>123 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year WHO region                Country Beverage Types  Display Value\n",
       "35    1985   Americas  Saint Kitts and Nevis        Spirits           2.24\n",
       "110   1985   Americas                 Brazil           Beer           1.42\n",
       "119   1985   Americas                  Chile           Beer           1.17\n",
       "258   1985   Americas                Bahamas           Wine           1.90\n",
       "298   1985   Americas              Argentina          Other           0.00\n",
       "...    ...        ...                    ...            ...            ...\n",
       "3092  1985   Americas              Guatemala           Wine           0.01\n",
       "3093  1985   Americas    Trinidad and Tobago        Spirits           2.84\n",
       "3121  1985   Americas               Paraguay          Other           0.00\n",
       "3146  1985   Americas            Saint Lucia           Wine           0.46\n",
       "3159  1985   Americas                   Peru          Other           0.00\n",
       "\n",
       "[123 rows x 5 columns]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con[(w_a_con['Year']==1985) & (w_a_con['WHO region']=='Americas')]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the alcohol consumption details in the year '1986' where WHO region is 'Western Pacific' and country is 'VietNam' from the world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The world alcohol consumption details in the year 1986 where WHO region is Western Pacific and country is VietNam :\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>898</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Other</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2100</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3239</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year       WHO region   Country Beverage Types  Display Value\n",
       "0     1986  Western Pacific  Viet Nam           Wine           0.00\n",
       "898   1986  Western Pacific  Viet Nam          Other            NaN\n",
       "2100  1986  Western Pacific  Viet Nam           Beer           0.12\n",
       "3239  1986  Western Pacific  Viet Nam        Spirits           0.05"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nThe world alcohol consumption details in the year 1986 where WHO region is Western Pacific and country is VietNam :\")\n",
    "w_a_con[(w_a_con['Year']==1986) & (w_a_con['WHO region']=='Western Pacific') & (w_a_con['Country']=='Viet Nam')]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the alcohol consumption details in the year '1986' or '1989' where WHO region is 'Americas' from the world alcohol consumption dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Antigua and Barbuda</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>1.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3211</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Canada</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3226</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Paraguay</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3227</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Bolivia (Plurinational State of)</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3232</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Paraguay</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>5.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3235</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Belize</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.35</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>248 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year WHO region                           Country Beverage Types  \\\n",
       "1     1986   Americas                           Uruguay          Other   \n",
       "3     1986   Americas                          Colombia           Beer   \n",
       "8     1986   Americas               Antigua and Barbuda        Spirits   \n",
       "11    1989   Americas                         Guatemala           Beer   \n",
       "21    1989   Americas                        Costa Rica        Spirits   \n",
       "...    ...        ...                               ...            ...   \n",
       "3211  1986   Americas                            Canada           Wine   \n",
       "3226  1986   Americas                          Paraguay           Wine   \n",
       "3227  1989   Americas  Bolivia (Plurinational State of)           Wine   \n",
       "3232  1986   Americas                          Paraguay        Spirits   \n",
       "3235  1986   Americas                            Belize           Beer   \n",
       "\n",
       "      Display Value  \n",
       "1              0.50  \n",
       "3              4.27  \n",
       "8              1.55  \n",
       "11             0.62  \n",
       "21             4.51  \n",
       "...             ...  \n",
       "3211           1.33  \n",
       "3226           0.36  \n",
       "3227           0.08  \n",
       "3232           5.17  \n",
       "3235           1.35  \n",
       "\n",
       "[248 rows x 5 columns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con[ w_a_con['WHO region']=='Americas'].query('Year == 1986 or Year==1989')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the alcohol consumption details in the year '1986' or '1989' where WHO region is 'Americas' or 'Europe' from the world alcohol consumption dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The world alcohol consumption details in the year ‘1986’ or ‘1989’ where  WHO region is ‘Americas’  or 'Europe':\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>1985</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>44</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Lithuania</td>\n",
       "      <td>Other</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Suriname</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Croatia</td>\n",
       "      <td>Wine</td>\n",
       "      <td>5.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>64</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Bolivia (Plurinational State of)</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Jamaica</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Year WHO region                                            Country  \\\n",
       "11  1989   Americas                                          Guatemala   \n",
       "21  1989   Americas                                         Costa Rica   \n",
       "26  1985     Europe  United Kingdom of Great Britain and Northern I...   \n",
       "35  1985   Americas                              Saint Kitts and Nevis   \n",
       "44  1985     Europe                                          Lithuania   \n",
       "50  1985     Europe                                        Switzerland   \n",
       "55  1989   Americas                                           Suriname   \n",
       "57  1989     Europe                                            Croatia   \n",
       "64  1989   Americas                   Bolivia (Plurinational State of)   \n",
       "78  1989   Americas                                            Jamaica   \n",
       "\n",
       "   Beverage Types  Display Value  \n",
       "11           Beer           0.62  \n",
       "21        Spirits           4.51  \n",
       "26           Wine           1.36  \n",
       "35        Spirits           2.24  \n",
       "44          Other            NaN  \n",
       "50          Other           0.30  \n",
       "55           Wine           0.04  \n",
       "57           Wine           5.10  \n",
       "64           Beer           1.26  \n",
       "78          Other           0.00  "
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nThe world alcohol consumption details in the year ‘1986’ or ‘1989’ where  WHO region is ‘Americas’  or 'Europe':\")\n",
    "w_a_con[((w_a_con['Year']==1985) | (w_a_con['Year']==1989)) & ((w_a_con['WHO region']=='Americas') \n",
    "         | (w_a_con['WHO region']=='Europe'))].head(10)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the records where consumption of beverages per person average >=5 and Beverage Types is Beer from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "The world alcohol consumption details: average consumption of \n",
      "beverages per person >=5 and Beverage Types is Beer:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Czech Republic</td>\n",
       "      <td>Beer</td>\n",
       "      <td>6.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Belgium</td>\n",
       "      <td>Beer</td>\n",
       "      <td>7.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>133</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Belgium</td>\n",
       "      <td>Beer</td>\n",
       "      <td>7.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>143</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Ireland</td>\n",
       "      <td>Beer</td>\n",
       "      <td>7.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>154</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Belgium</td>\n",
       "      <td>Beer</td>\n",
       "      <td>7.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>241</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>Beer</td>\n",
       "      <td>6.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>247</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Gabon</td>\n",
       "      <td>Beer</td>\n",
       "      <td>6.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>293</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Gabon</td>\n",
       "      <td>Beer</td>\n",
       "      <td>8.33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>325</th>\n",
       "      <td>1985</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Australia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>7.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>352</th>\n",
       "      <td>1984</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Canada</td>\n",
       "      <td>Beer</td>\n",
       "      <td>5.00</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     Year       WHO region                                            Country  \\\n",
       "41   1986           Europe                                     Czech Republic   \n",
       "115  1986           Europe                                            Belgium   \n",
       "133  1989           Europe                                            Belgium   \n",
       "143  1987           Europe                                            Ireland   \n",
       "154  1987           Europe                                            Belgium   \n",
       "241  1986           Europe  United Kingdom of Great Britain and Northern I...   \n",
       "247  1989           Africa                                              Gabon   \n",
       "293  1985           Africa                                              Gabon   \n",
       "325  1985  Western Pacific                                          Australia   \n",
       "352  1984         Americas                                             Canada   \n",
       "\n",
       "    Beverage Types  Display Value  \n",
       "41            Beer           6.82  \n",
       "115           Beer           7.36  \n",
       "133           Beer           7.01  \n",
       "143           Beer           7.49  \n",
       "154           Beer           7.42  \n",
       "241           Beer           6.73  \n",
       "247           Beer           6.49  \n",
       "293           Beer           8.33  \n",
       "325           Beer           7.73  \n",
       "352           Beer           5.00  "
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nThe world alcohol consumption details: average consumption of \\nbeverages per person >=5 and Beverage Types is Beer:\")\n",
    "w_a_con[(w_a_con['Display Value'] >= 5) & (w_a_con['Beverage Types'] == 'Beer')].head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find out the records where consumption of beverages per person average >=4 and Beverage Types is Beer, Wine, Spirits from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Czech Republic</td>\n",
       "      <td>Beer</td>\n",
       "      <td>6.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Croatia</td>\n",
       "      <td>Wine</td>\n",
       "      <td>5.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Bulgaria</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3214</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>Beer</td>\n",
       "      <td>5.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3220</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3232</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Paraguay</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>5.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3247</th>\n",
       "      <td>1984</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Latvia</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>7.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3248</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Bulgaria</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.32</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>249 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year WHO region                                            Country  \\\n",
       "3     1986   Americas                                           Colombia   \n",
       "21    1989   Americas                                         Costa Rica   \n",
       "41    1986     Europe                                     Czech Republic   \n",
       "57    1989     Europe                                            Croatia   \n",
       "91    1989     Europe                                           Bulgaria   \n",
       "...    ...        ...                                                ...   \n",
       "3214  1987     Europe  United Kingdom of Great Britain and Northern I...   \n",
       "3220  1986     Africa                                           Zimbabwe   \n",
       "3232  1986   Americas                                           Paraguay   \n",
       "3247  1984     Europe                                             Latvia   \n",
       "3248  1986     Europe                                           Bulgaria   \n",
       "\n",
       "     Beverage Types  Display Value  \n",
       "3              Beer           4.27  \n",
       "21          Spirits           4.51  \n",
       "41             Beer           6.82  \n",
       "57             Wine           5.10  \n",
       "91             Beer           4.43  \n",
       "...             ...            ...  \n",
       "3214           Beer           5.49  \n",
       "3220        Spirits           5.57  \n",
       "3232        Spirits           5.17  \n",
       "3247        Spirits           7.50  \n",
       "3248        Spirits           4.32  \n",
       "\n",
       "[249 rows x 5 columns]"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con[(w_a_con['Display Value'] >= 4) & (w_a_con['Beverage Types'].isin(['Beer','Wine','Spirits']))]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter the specified columns and records by range from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Filtering records by label or index:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Beverage Types</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Americas</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Africa</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Americas</td>\n",
       "      <td>Beer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Americas</td>\n",
       "      <td>Beer</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        WHO region Beverage Types\n",
       "0  Western Pacific           Wine\n",
       "1         Americas          Other\n",
       "2           Africa           Wine\n",
       "3         Americas           Beer\n",
       "4         Americas           Beer"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFiltering records by label or index:\")\n",
    "w_a_con.loc[0:4, [\"WHO region\", \"Beverage Types\"]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter those records where WHO region contains \"Ea\" substring from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Match if  a given column has a particular sub string:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>1984</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1986</td>\n",
       "      <td>South-East Asia</td>\n",
       "      <td>Myanmar</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>1984</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Tunisia</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>1984</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Bahrain</td>\n",
       "      <td>Beer</td>\n",
       "      <td>2.22</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>1987</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Egypt</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3223</th>\n",
       "      <td>1984</td>\n",
       "      <td>South-East Asia</td>\n",
       "      <td>Democratic People's Republic of Korea</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3231</th>\n",
       "      <td>1989</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Morocco</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3241</th>\n",
       "      <td>1984</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Djibouti</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3244</th>\n",
       "      <td>1986</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>United Arab Emirates</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3245</th>\n",
       "      <td>1985</td>\n",
       "      <td>South-East Asia</td>\n",
       "      <td>India</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>1.24</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>565 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year             WHO region                                Country  \\\n",
       "13    1984  Eastern Mediterranean                            Afghanistan   \n",
       "20    1986        South-East Asia                                Myanmar   \n",
       "25    1984  Eastern Mediterranean                                Tunisia   \n",
       "27    1984  Eastern Mediterranean                                Bahrain   \n",
       "36    1987  Eastern Mediterranean                                  Egypt   \n",
       "...    ...                    ...                                    ...   \n",
       "3223  1984        South-East Asia  Democratic People's Republic of Korea   \n",
       "3231  1989  Eastern Mediterranean                                Morocco   \n",
       "3241  1984  Eastern Mediterranean                               Djibouti   \n",
       "3244  1986  Eastern Mediterranean                   United Arab Emirates   \n",
       "3245  1985        South-East Asia                                  India   \n",
       "\n",
       "     Beverage Types  Display Value  \n",
       "13            Other           0.00  \n",
       "20             Wine           0.00  \n",
       "25            Other           0.00  \n",
       "27             Beer           2.22  \n",
       "36             Beer           0.07  \n",
       "...             ...            ...  \n",
       "3223           Beer           0.37  \n",
       "3231        Spirits           0.07  \n",
       "3241           Wine           0.51  \n",
       "3244          Other           0.00  \n",
       "3245        Spirits           1.24  \n",
       "\n",
       "[565 rows x 5 columns]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Remove NA / NaN values\n",
    "new_w_a_con = w_a_con.dropna()\n",
    "print(\"\\nMatch if  a given column has a particular sub string:\")\n",
    "new_w_a_con[new_w_a_con[\"WHO region\"].str.contains(\"Ea\")]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter those records where WHO region matches with multiple values (Africa, Eastern Mediterranean, Europe) from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Filter by matching multiple values in a given dataframe:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Angola</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Nigeria</td>\n",
       "      <td>Other</td>\n",
       "      <td>6.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Botswana</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3250</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Iceland</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3251</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Angola</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "      <td>5.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2059 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year WHO region                   Country Beverage Types  Display Value\n",
       "2     1985     Africa              Cte d'Ivoire           Wine           1.62\n",
       "6     1987     Africa                 Mauritius           Wine           0.13\n",
       "7     1985     Africa                    Angola        Spirits           0.39\n",
       "9     1984     Africa                   Nigeria          Other           6.10\n",
       "10    1987     Africa                  Botswana           Wine           0.20\n",
       "...    ...        ...                       ...            ...            ...\n",
       "3250  1987     Europe                   Iceland          Other           0.01\n",
       "3251  1984     Africa                    Angola           Wine           0.57\n",
       "3252  1984     Africa  Central African Republic           Wine           0.46\n",
       "3254  1986     Europe               Switzerland        Spirits           2.54\n",
       "3256  1986     Africa                 Swaziland          Other           5.15\n",
       "\n",
       "[2059 rows x 5 columns]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFilter by matching multiple values in a given dataframe:\")\n",
    "w_a_con.loc[w_a_con[\"WHO region\"].isin([\"Africa\", \"Eastern Mediterranean\", \"Europe\"])]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter all records where the average consumption of beverages per person from .5 to 2.50 in world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Filter all records where the average consumption of beverages per person from .5 to 2.50.:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Antigua and Barbuda</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>1.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>1989</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Seychelles</td>\n",
       "      <td>Beer</td>\n",
       "      <td>2.23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Year WHO region                Country Beverage Types  Display Value\n",
       "2   1985     Africa           Cte d'Ivoire           Wine           1.62\n",
       "4   1987   Americas  Saint Kitts and Nevis           Beer           1.98\n",
       "8   1986   Americas    Antigua and Barbuda        Spirits           1.55\n",
       "11  1989   Americas              Guatemala           Beer           0.62\n",
       "17  1989     Africa             Seychelles           Beer           2.23"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFilter all records where the average consumption of beverages per person from .5 to 2.50.:\")\n",
    "w_a_con[(w_a_con['Display Value'] < 2.5) & (w_a_con['Display Value']>.5)].head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find average consumption of wine per person greater than 2 in world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Average consumption of wine per person greater than 2:\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Year              326\n",
       "WHO region        326\n",
       "Country           326\n",
       "Beverage Types    326\n",
       "Display Value     326\n",
       "dtype: int64"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nAverage consumption of wine per person greater than 2:\")\n",
    "w_a_con[(w_a_con['Beverage Types'] == 'Wine') & (w_a_con['Display Value'] > .2)].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Russian Federation</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>49</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Malta</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>1989</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Croatia</td>\n",
       "      <td>Wine</td>\n",
       "      <td>5.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3226</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Paraguay</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3241</th>\n",
       "      <td>1984</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Djibouti</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3243</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Slovakia</td>\n",
       "      <td>Wine</td>\n",
       "      <td>2.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3251</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Angola</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>326 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year             WHO region  \\\n",
       "2     1985                 Africa   \n",
       "26    1985                 Europe   \n",
       "34    1986                 Europe   \n",
       "49    1986                 Europe   \n",
       "57    1989                 Europe   \n",
       "...    ...                    ...   \n",
       "3226  1986               Americas   \n",
       "3241  1984  Eastern Mediterranean   \n",
       "3243  1985                 Europe   \n",
       "3251  1984                 Africa   \n",
       "3252  1984                 Africa   \n",
       "\n",
       "                                                Country Beverage Types  \\\n",
       "2                                          Cte d'Ivoire           Wine   \n",
       "26    United Kingdom of Great Britain and Northern I...           Wine   \n",
       "34                                   Russian Federation           Wine   \n",
       "49                                                Malta           Wine   \n",
       "57                                              Croatia           Wine   \n",
       "...                                                 ...            ...   \n",
       "3226                                           Paraguay           Wine   \n",
       "3241                                           Djibouti           Wine   \n",
       "3243                                           Slovakia           Wine   \n",
       "3251                                             Angola           Wine   \n",
       "3252                           Central African Republic           Wine   \n",
       "\n",
       "      Display Value  \n",
       "2              1.62  \n",
       "26             1.36  \n",
       "34             0.80  \n",
       "49             1.49  \n",
       "57             5.10  \n",
       "...             ...  \n",
       "3226           0.36  \n",
       "3241           0.51  \n",
       "3243           2.60  \n",
       "3251           0.57  \n",
       "3252           0.46  \n",
       "\n",
       "[326 rows x 5 columns]"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con[(w_a_con['Beverage Types'] == 'Wine') & (w_a_con['Display Value'] > .2)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter rows based on row numbers ended with 0, like 0, 10, 20, 30 from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Filter rows based on row numbers ended with 0, like 0, 10, 20, 30:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Botswana</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>1986</td>\n",
       "      <td>South-East Asia</td>\n",
       "      <td>Myanmar</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Sierra Leone</td>\n",
       "      <td>Other</td>\n",
       "      <td>4.48</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Austria</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>1.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3210</th>\n",
       "      <td>1986</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Djibouti</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3220</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Zimbabwe</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>5.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3230</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>France</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3240</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Slovenia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>3.71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3250</th>\n",
       "      <td>1987</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Iceland</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.01</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>326 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      Year             WHO region       Country Beverage Types  Display Value\n",
       "0     1986        Western Pacific      Viet Nam           Wine           0.00\n",
       "10    1987                 Africa      Botswana           Wine           0.20\n",
       "20    1986        South-East Asia       Myanmar           Wine           0.00\n",
       "30    1986                 Africa  Sierra Leone          Other           4.48\n",
       "40    1987                 Europe       Austria        Spirits           1.90\n",
       "...    ...                    ...           ...            ...            ...\n",
       "3210  1986  Eastern Mediterranean      Djibouti          Other           0.00\n",
       "3220  1986                 Africa      Zimbabwe        Spirits           5.57\n",
       "3230  1987                 Europe        France        Spirits           2.77\n",
       "3240  1986                 Europe      Slovenia           Beer           3.71\n",
       "3250  1987                 Europe       Iceland          Other           0.01\n",
       "\n",
       "[326 rows x 5 columns]"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFilter rows based on row numbers ended with 0, like 0, 10, 20, 30:\")\n",
    "w_a_con.filter(regex='0$', axis=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to select consecutive columns and also select rows with Index label 0 to 9 with some columns from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select consecutive columns:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Country Beverage Types  Display Value\n",
       "0               Viet Nam           Wine           0.00\n",
       "1                Uruguay          Other           0.50\n",
       "2           Cte d'Ivoire           Wine           1.62\n",
       "3               Colombia           Beer           4.27\n",
       "4  Saint Kitts and Nevis           Beer           1.98"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect consecutive columns:\")\n",
    "w_a_con.loc[:,\"Country\":\"Display Value\"].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Alternate command:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 Country Beverage Types  Display Value\n",
       "0               Viet Nam           Wine           0.00\n",
       "1                Uruguay          Other           0.50\n",
       "2           Cte d'Ivoire           Wine           1.62\n",
       "3               Colombia           Beer           4.27\n",
       "4  Saint Kitts and Nevis           Beer           1.98"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nAlternate command:\")\n",
    "w_a_con.iloc[:,2:5].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Select rows with Index label 0 to 9 with specific columns:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Country</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1987</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1987</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>0.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1985</td>\n",
       "      <td>Angola</td>\n",
       "      <td>0.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1986</td>\n",
       "      <td>Antigua and Barbuda</td>\n",
       "      <td>1.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1984</td>\n",
       "      <td>Nigeria</td>\n",
       "      <td>6.10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year                Country  Display Value\n",
       "0  1986               Viet Nam           0.00\n",
       "1  1986                Uruguay           0.50\n",
       "2  1985           Cte d'Ivoire           1.62\n",
       "3  1986               Colombia           4.27\n",
       "4  1987  Saint Kitts and Nevis           1.98\n",
       "5  1987              Guatemala           0.00\n",
       "6  1987              Mauritius           0.13\n",
       "7  1985                 Angola           0.39\n",
       "8  1986    Antigua and Barbuda           1.55\n",
       "9  1984                Nigeria           6.10"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nSelect rows with Index label 0 to 9 with specific columns:\")\n",
    "w_a_con.loc[0:9,[\"Year\",\"Country\",\"Display Value\"]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to rename all and only some of the column names from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "metadata": {},
   "outputs": [],
   "source": [
    "w_a_con.columns = ['year','who_region','country','beverage_types','display_values']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>who_region</th>\n",
       "      <th>country</th>\n",
       "      <th>beverage_types</th>\n",
       "      <th>display_values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   year       who_region                country beverage_types  display_values\n",
       "0  1986  Western Pacific               Viet Nam           Wine            0.00\n",
       "1  1986         Americas                Uruguay          Other            0.50\n",
       "2  1985           Africa           Cte d'Ivoire           Wine            1.62\n",
       "3  1986         Americas               Colombia           Beer            4.27\n",
       "4  1987         Americas  Saint Kitts and Nevis           Beer            1.98"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Renaming only some of the column names:\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda\\lib\\site-packages\\pandas\\core\\frame.py:4133: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  errors=errors,\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>who_region</th>\n",
       "      <th>country</th>\n",
       "      <th>beverage_types</th>\n",
       "      <th>display_values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   year       who_region                country beverage_types  display_values\n",
       "0  1986  Western Pacific               Viet Nam           Wine            0.00\n",
       "1  1986         Americas                Uruguay          Other            0.50\n",
       "2  1985           Africa           Cte d'Ivoire           Wine            1.62\n",
       "3  1986         Americas               Colombia           Beer            4.27\n",
       "4  1987         Americas  Saint Kitts and Nevis           Beer            1.98"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nRenaming only some of the column names:\")\n",
    "new_w_a_con.rename(columns = {\"WHO region\":\"WHO_region\",\"Display Value\":\"Display_Value\" },inplace = True)\n",
    "w_a_con.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to find which years have all non-zero values and which years have any non-zero values from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Find which years have all non-zero values:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>who_region</th>\n",
       "      <th>country</th>\n",
       "      <th>beverage_types</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Fiji</td>\n",
       "      <td>Spirits</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Papua New Guinea</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3257 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      year       who_region                   country beverage_types\n",
       "0     1986  Western Pacific                  Viet Nam           Wine\n",
       "1     1986         Americas                   Uruguay          Other\n",
       "2     1985           Africa              Cte d'Ivoire           Wine\n",
       "3     1986         Americas                  Colombia           Beer\n",
       "4     1987         Americas     Saint Kitts and Nevis           Beer\n",
       "...    ...              ...                       ...            ...\n",
       "3252  1984           Africa  Central African Republic           Wine\n",
       "3253  1986  Western Pacific                      Fiji        Spirits\n",
       "3254  1986           Europe               Switzerland        Spirits\n",
       "3255  1987  Western Pacific          Papua New Guinea          Other\n",
       "3256  1986           Africa                 Swaziland          Other\n",
       "\n",
       "[3257 rows x 4 columns]"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFind which years have all non-zero values:\")\n",
    "w_a_con.loc[:,w_a_con.all()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Find which years have any non-zero values:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>who_region</th>\n",
       "      <th>country</th>\n",
       "      <th>beverage_types</th>\n",
       "      <th>display_values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Fiji</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Papua New Guinea</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "      <td>5.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3257 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      year       who_region                   country beverage_types  \\\n",
       "0     1986  Western Pacific                  Viet Nam           Wine   \n",
       "1     1986         Americas                   Uruguay          Other   \n",
       "2     1985           Africa              Cte d'Ivoire           Wine   \n",
       "3     1986         Americas                  Colombia           Beer   \n",
       "4     1987         Americas     Saint Kitts and Nevis           Beer   \n",
       "...    ...              ...                       ...            ...   \n",
       "3252  1984           Africa  Central African Republic           Wine   \n",
       "3253  1986  Western Pacific                      Fiji        Spirits   \n",
       "3254  1986           Europe               Switzerland        Spirits   \n",
       "3255  1987  Western Pacific          Papua New Guinea          Other   \n",
       "3256  1986           Africa                 Swaziland          Other   \n",
       "\n",
       "      display_values  \n",
       "0               0.00  \n",
       "1               0.50  \n",
       "2               1.62  \n",
       "3               4.27  \n",
       "4               1.98  \n",
       "...              ...  \n",
       "3252            0.46  \n",
       "3253            0.05  \n",
       "3254            2.54  \n",
       "3255            0.00  \n",
       "3256            5.15  \n",
       "\n",
       "[3257 rows x 5 columns]"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFind which years have any non-zero values:\")\n",
    "w_a_con.loc[:,w_a_con.any()]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter all columns where all entries present, check which rows and columns has a NaN and finally drop rows with any NaNs from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Find  all columns which all entries present:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>who_region</th>\n",
       "      <th>country</th>\n",
       "      <th>beverage_types</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Fiji</td>\n",
       "      <td>Spirits</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Papua New Guinea</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3257 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      year       who_region                   country beverage_types\n",
       "0     1986  Western Pacific                  Viet Nam           Wine\n",
       "1     1986         Americas                   Uruguay          Other\n",
       "2     1985           Africa              Cte d'Ivoire           Wine\n",
       "3     1986         Americas                  Colombia           Beer\n",
       "4     1987         Americas     Saint Kitts and Nevis           Beer\n",
       "...    ...              ...                       ...            ...\n",
       "3252  1984           Africa  Central African Republic           Wine\n",
       "3253  1986  Western Pacific                      Fiji        Spirits\n",
       "3254  1986           Europe               Switzerland        Spirits\n",
       "3255  1987  Western Pacific          Papua New Guinea          Other\n",
       "3256  1986           Africa                 Swaziland          Other\n",
       "\n",
       "[3257 rows x 4 columns]"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nFind  all columns which all entries present:\")\n",
    "w_a_con.loc[:, w_a_con.notnull().all()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Rows and columns has a NaN:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>display_values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>2.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>5.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3257 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      display_values\n",
       "0               0.00\n",
       "1               0.50\n",
       "2               1.62\n",
       "3               4.27\n",
       "4               1.98\n",
       "...              ...\n",
       "3252            0.46\n",
       "3253            0.05\n",
       "3254            2.54\n",
       "3255            0.00\n",
       "3256            5.15\n",
       "\n",
       "[3257 rows x 1 columns]"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nRows and columns has a NaN:\")\n",
    "w_a_con.loc[:,w_a_con.isnull().any()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Drop rows with any NaNs:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>who_region</th>\n",
       "      <th>country</th>\n",
       "      <th>beverage_types</th>\n",
       "      <th>display_values</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>Beer</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>Beer</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3252</th>\n",
       "      <td>1984</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Central African Republic</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3253</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Fiji</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>0.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3254</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.54</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3255</th>\n",
       "      <td>1987</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Papua New Guinea</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3256</th>\n",
       "      <td>1986</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Swaziland</td>\n",
       "      <td>Other</td>\n",
       "      <td>5.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3035 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      year       who_region                   country beverage_types  \\\n",
       "0     1986  Western Pacific                  Viet Nam           Wine   \n",
       "1     1986         Americas                   Uruguay          Other   \n",
       "2     1985           Africa              Cte d'Ivoire           Wine   \n",
       "3     1986         Americas                  Colombia           Beer   \n",
       "4     1987         Americas     Saint Kitts and Nevis           Beer   \n",
       "...    ...              ...                       ...            ...   \n",
       "3252  1984           Africa  Central African Republic           Wine   \n",
       "3253  1986  Western Pacific                      Fiji        Spirits   \n",
       "3254  1986           Europe               Switzerland        Spirits   \n",
       "3255  1987  Western Pacific          Papua New Guinea          Other   \n",
       "3256  1986           Africa                 Swaziland          Other   \n",
       "\n",
       "      display_values  \n",
       "0               0.00  \n",
       "1               0.50  \n",
       "2               1.62  \n",
       "3               4.27  \n",
       "4               1.98  \n",
       "...              ...  \n",
       "3252            0.46  \n",
       "3253            0.05  \n",
       "3254            2.54  \n",
       "3255            0.00  \n",
       "3256            5.15  \n",
       "\n",
       "[3035 rows x 5 columns]"
      ]
     },
     "execution_count": 82,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nDrop rows with any NaNs:\")\n",
    "w_a_con.dropna(how='any')  "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter all records starting from the 'Year' column, access every other column from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "From the 'Year' column, access every other column:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>Country</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1986</td>\n",
       "      <td>Viet Nam</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1985</td>\n",
       "      <td>Cte d'Ivoire</td>\n",
       "      <td>1.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1986</td>\n",
       "      <td>Colombia</td>\n",
       "      <td>4.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1987</td>\n",
       "      <td>Saint Kitts and Nevis</td>\n",
       "      <td>1.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1987</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1987</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>0.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1985</td>\n",
       "      <td>Angola</td>\n",
       "      <td>0.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>1986</td>\n",
       "      <td>Antigua and Barbuda</td>\n",
       "      <td>1.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1984</td>\n",
       "      <td>Nigeria</td>\n",
       "      <td>6.10</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Year                Country  Display Value\n",
       "0  1986               Viet Nam           0.00\n",
       "1  1986                Uruguay           0.50\n",
       "2  1985           Cte d'Ivoire           1.62\n",
       "3  1986               Colombia           4.27\n",
       "4  1987  Saint Kitts and Nevis           1.98\n",
       "5  1987              Guatemala           0.00\n",
       "6  1987              Mauritius           0.13\n",
       "7  1985                 Angola           0.39\n",
       "8  1986    Antigua and Barbuda           1.55\n",
       "9  1984                Nigeria           6.10"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_a_con = pd.read_csv('https://raw.githubusercontent.com/ustutz/Dataquest/master/Data_Analyst/Step_2_Intermediate_Python_and_Pandas/2_Data_Analysis_with_Pandas_Intermediate/2_Computation_with_NumPy/5_Replacing_values/world_alcohol.csv')\n",
    "print(\"\\nFrom the 'Year' column, access every other column:\")\n",
    "w_a_con.loc[:,'Year'::2].head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Write a Pandas program to filter all records starting from the 2nd row, access every 5th row from world alcohol consumption dataset.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Starting from the 2nd row, access every 5th row:\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Year</th>\n",
       "      <th>WHO region</th>\n",
       "      <th>Country</th>\n",
       "      <th>Beverage Types</th>\n",
       "      <th>Display Value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1986</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Uruguay</td>\n",
       "      <td>Other</td>\n",
       "      <td>0.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1987</td>\n",
       "      <td>Africa</td>\n",
       "      <td>Mauritius</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Guatemala</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1984</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>1989</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Costa Rica</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>4.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>1985</td>\n",
       "      <td>Europe</td>\n",
       "      <td>United Kingdom of Great Britain and Northern I...</td>\n",
       "      <td>Wine</td>\n",
       "      <td>1.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>1986</td>\n",
       "      <td>Western Pacific</td>\n",
       "      <td>Micronesia (Federated States of)</td>\n",
       "      <td>Wine</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>1987</td>\n",
       "      <td>Eastern Mediterranean</td>\n",
       "      <td>Egypt</td>\n",
       "      <td>Beer</td>\n",
       "      <td>0.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>1986</td>\n",
       "      <td>Europe</td>\n",
       "      <td>Czech Republic</td>\n",
       "      <td>Beer</td>\n",
       "      <td>6.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>1987</td>\n",
       "      <td>Americas</td>\n",
       "      <td>Trinidad and Tobago</td>\n",
       "      <td>Spirits</td>\n",
       "      <td>2.26</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Year             WHO region  \\\n",
       "1   1986               Americas   \n",
       "6   1987                 Africa   \n",
       "11  1989               Americas   \n",
       "16  1984               Americas   \n",
       "21  1989               Americas   \n",
       "26  1985                 Europe   \n",
       "31  1986        Western Pacific   \n",
       "36  1987  Eastern Mediterranean   \n",
       "41  1986                 Europe   \n",
       "46  1987               Americas   \n",
       "\n",
       "                                              Country Beverage Types  \\\n",
       "1                                             Uruguay          Other   \n",
       "6                                           Mauritius           Wine   \n",
       "11                                          Guatemala           Beer   \n",
       "16                                         Costa Rica           Wine   \n",
       "21                                         Costa Rica        Spirits   \n",
       "26  United Kingdom of Great Britain and Northern I...           Wine   \n",
       "31                   Micronesia (Federated States of)           Wine   \n",
       "36                                              Egypt           Beer   \n",
       "41                                     Czech Republic           Beer   \n",
       "46                                Trinidad and Tobago        Spirits   \n",
       "\n",
       "    Display Value  \n",
       "1            0.50  \n",
       "6            0.13  \n",
       "11           0.62  \n",
       "16           0.06  \n",
       "21           4.51  \n",
       "26           1.36  \n",
       "31           0.00  \n",
       "36           0.07  \n",
       "41           6.82  \n",
       "46           2.26  "
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(\"\\nStarting from the 2nd row, access every 5th row:\")\n",
    "w_a_con.iloc[1::5].head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
